import React from 'react'
import { getMovieAction } from '../../store/actions/movieAction';
import store from '../../store/store'

export default function Movie() {
  const { count } = store.getState().count;
  //在这个位置收到电影列表
  //获取数据
  const { movieList } = store.getState().movie

  //点击时发送请求
  const getMovieHandle = () => {
    store.dispatch(getMovieAction())
  }

  return (
    <div>
      <h1>我是Movie组件</h1>
      <p>我收到的Count组件的值是 {count}</p>
      <button onClick={getMovieHandle}>获取电影的数据</button>
      <ul>
        {movieList.map(item => {
          return <li key = {item.tvId}>{item.name}</li>
        })}
      </ul>
    </div>
  )
}
